#pragma once 
#include "timer.h"
namespace TinyRPC {

Timer::Timer(const TimeStamp& startTime, const TimeStamp& interval, const Task& task)
: m_startTime(startTime)
, m_interval(interval)
, m_task(task){

}
void Timer::runTask(){
    m_task.run();
}
bool Timer::isPeriod(){
    return  TimeStamp(0) < m_interval ;
}
void Timer::nextPeriod(){
    m_startTime = TimeStamp::Now() + m_interval;
}

 bool Timer::operator<(const Timer& timer) const{
     return m_startTime < timer.m_startTime;
 }
bool Timer::operator==(const Timer& timer) const {
     return m_startTime == timer.m_startTime;
 }
bool Timer::operator>(const Timer& timer) const{
     return m_startTime > timer.m_startTime;
 }

}
